//
//  NetWork.h
//  TheProjectFrameWork
//
//  Created by maple on 16/6/4.
//  Copyright © 2016年 MapleDongSen. All rights reserved.
//

#import <Foundation/Foundation.h>
@interface NetWork : NSObject
/** 成功回调 */
typedef void(^SuccessBlock)(NSDictionary * dic);
/** 失败回调 */
typedef void(^ErrorBlock)(NSString * error);

/** 成功回调 state = 0 */
typedef void(^SuccessCallBack)(NSDictionary * dic);
/** 错误回调 */
typedef void(^ErrorCallBack)(id error);
/** 失败 state ！= 0 */
typedef void(^FailureCallBack)(NSString * msg);


typedef void(^CompleteBackCallBlock) (id error);

typedef void(^ImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize);
typedef void(^ImageCompletionWithFinishedBlock)(UIImage *image, NSError *error, BOOL finished, NSURL *imageURL);


/**
 *  POST请求
 *
 *  @param url        地址
 *  @param data       参数
 *  @param dicback    成功回调data内容
 *  @param msgback    成功但state ！=1
 *  @param errorblock 失败回调
 */
+ (void)postNetWorkWithUrl:(NSString *)url parame:(id)parame successBlock:(SuccessCallBack)dicback errorBlock:(ErrorCallBack)errorblock;



/**
 *  下载图片
 *
 *  @param url             图片url
 *  @param progressBlock   下载进度
 *  @param completionBlock 完成回调
 */
+ (void)loadImageWithUrl:(NSString *)url ImageDownloaderProgressBlock:(ImageDownloaderProgressBlock)progressBlock
ImageCompletionWithFinishedBlock:(ImageCompletionWithFinishedBlock)completionBlock;

/**
 *  上传图片
 *
 *  @param url              图片上传url
 *  @param imagePath        图片路径
 *  @param imageName        图片名称
 *  @param successBlock     成功回调
 *  @param errorBlock       失败回调
 */
+ (void)uploadImageWithUrl:(NSString *)url image:(UIImage *)image imageName:(NSString *)imageName successBlock:(SuccessCallBack)dicback errorBlock:(ErrorCallBack)errorblock;

@end
